<template>
 <div class="wechat">
    <!-- 卡片视图区域 -->
    <div class="wechat_card">
      <!-- 布局 -->
      <el-row :gutter="20" class="wechat_card_head" type="flex">
        <el-col :span="6">
          <!-- 搜索框及添加区域 -->
          <el-input
            placeholder="请输入业主姓名"
            v-model="queryInfo.query"
            clearable
            @clear="getOwnerInfoList"
            size="medium"
          >
            <el-button
              slot="append"
              size="medium"
              icon="el-icon-search"
              @click="getOwnerInfoList"
            ></el-button> </el-input
        ></el-col>
         <el-button
          size="medium"
          class="btn_head_medium"
          type="primary"
          @click="addDialogVisible = true"
          icon="el-icon-circle-plus-outline"
          >新增</el-button
        >

        <el-button
          size="medium"
          type="danger"
          @click="removeUserByIds"
          icon="el-icon-remove-outline"
          >删除</el-button
        >
        <!-- 婚姻状况筛选 -->
        <el-select
          class="select_head_medium"
          size="medium"
          v-model="marryInfoValue"
          @change="selectChange"
          clearable
          collapse-tags
          placeholder="按婚姻状况筛选"
          
        >
          <el-option label="未婚" value="未婚"></el-option>
          <el-option label="已婚" value="已婚"></el-option>
          <el-option label="离婚" value="离婚"></el-option>
          <el-option label="丧偶" value="丧偶"></el-option>
        </el-select>
        <!-- 文化程度筛选 -->
        <el-select
          class="select_head_medium"
          size="medium"
          v-model="eduInfoValue"
          @change="selectChange"
          clearable
          collapse-tags
          multiple
          placeholder="按文化程度筛选"
          
        >
          <el-option label="博士" value="博士"></el-option>
          <el-option label="研究生" value="研究生"></el-option>
          <el-option label="本科" value="本科"></el-option>
          <el-option label="大专或中专" value="大专或中专"></el-option>
          <el-option label="高中" value="高中"></el-option>
          <el-option label="初中" value="初中"></el-option>
          <el-option label="小学" value="小学"></el-option>
          <el-option label="文盲" value="文盲"></el-option>
        </el-select>
        <!-- 兵役状况筛选 -->
        <el-select
          class="select_head_medium"
          size="medium"
          v-model="serviceValue"
          @change="selectChange"
          clearable
          collapse-tags
          placeholder="按兵役状况筛选"
         
        >
          <el-option label="未服役" value="0"></el-option>
          <el-option label="服役" value="1"></el-option>
        </el-select>
       <!-- 表格列筛选 -->
        <div class="tools_head">
          <el-popover placement="bottom" trigger="click">
            <el-checkbox-group v-model="colOptions">
              <el-checkbox
                v-for="item in colSelect"
                :label="item"
                :key="item"
                style="display: block; margin: 10px"
              >
              </el-checkbox>
            </el-checkbox-group>
            <div slot="reference">
              <el-tooltip content="筛选列" placement="bottom">
                <el-button size="small" icon="el-icon-menu"></el-button>
              </el-tooltip>
            </div>
            <el-button
              size="small"
              type="text"
              @click="filterFunHandle('allchecked')"
              >全选</el-button
            >
            <el-button
              size="small"
              type="text"
              @click="filterFunHandle('cancel')"
              >取消全选</el-button
            >
          </el-popover>
          <el-tooltip content="导出excel" placement="bottom">
            <el-button
              size="small"
              icon="el-icon-download"
              style="margin-left: 10px"
              @click="handleDownload"
            ></el-button>
          </el-tooltip>
        </div>
      </el-row>
      <!-- 业主列表区域 -->
      <el-table
        :data="ownerInfoList"
        style="width: 100%"
        height="85%"
        size="small"
        border
        stripe
        tooltip-effect="dark"
        :row-key="
          (row) => {
            return row.id;
          }
        "
        @selection-change="handleSelectionChange"
        :header-cell-style="{ textAlign: 'center' }"
        :cell-style="{ textAlign: 'center' }"
        ref="tableDataRef"
      >
        <el-table-column type="selection" :reserve-selection="true"> </el-table-column>
        <el-table-column
          v-if="colData[0].istrue"
          type="index"
          label="序号"
        ></el-table-column>
        <el-table-column v-if="colData[1].istrue" prop="name" label="姓名">
        </el-table-column>
        <el-table-column v-if="colData[2].istrue" prop="gender" label="性别">
        </el-table-column>
        <el-table-column
          v-if="colData[3].istrue"
          prop="phone"
          label="联系电话"
          width="130px"
        >
        </el-table-column>
        
        <el-table-column
          v-if="colData[4].istrue"
          prop="roomNo"
          label="房间号"
        ></el-table-column>
         <el-table-column
          v-if="colData[5].istrue"
          prop="floorName"
          label="楼栋号"
        ></el-table-column>
         <el-table-column
          v-if="colData[6].istrue"
          prop="floorUnitName"
          label="单元号"
        ></el-table-column>
        <el-table-column
          v-if="colData[7].istrue"
          prop="jobInfo"
          label="职业"
        ></el-table-column>
        <el-table-column
          v-if="colData[8].istrue"
          prop="marryInfo"
          label="婚姻状况"
        ></el-table-column>
        <el-table-column
          v-if="colData[9].istrue"
          prop="nativePlace"
          label="籍贯"
        ></el-table-column>
        <el-table-column
          v-if="colData[10].istrue"
          prop="eduInfo"
          label="文化程度"
          width="120px"
        ></el-table-column>
        <el-table-column
          v-if="colData[11].istrue"
          prop="militaryState"
          label="兵役状况"
          width="100px"
          column-key="militaryState"
          :filters="[
            { text: '未服役', value: 0 },
            { text: '服役', value: 1 },
          ]"
          :filter-method="filterTag"
          filter-placement="bottom-end"
        >
          <template slot-scope="scope">
            <el-tag v-if="scope.row.militaryState === 0" type="success"
              >未服役</el-tag
            >
            <el-tag v-else type="danger">服役</el-tag>
          </template>
        </el-table-column>
        <el-table-column
          v-if="colData[12].istrue"
          prop="userType"
          label="客户类型"
          width="100px"
        >
          <template slot-scope="scope">
            <el-tag v-if="scope.row.userType === 0" type="success">业主</el-tag>
            <el-tag v-else-if="scope.row.userType === 1" type="danger"
              >家庭成员</el-tag
            >
            <el-tag v-else type="warning">入住人员</el-tag>
          </template>
        </el-table-column>
        <el-table-column
          v-if="colData[13].istrue"
          prop="nation"
          label="民族"
        ></el-table-column>
        <el-table-column
          v-if="colData[14].istrue"
          prop="idCard"
          label="身份证号"
          width="180px"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          v-if="colData[15].istrue"
          prop="religious"
          label="宗教信仰"
        ></el-table-column>
        <el-table-column
          v-if="colData[16].istrue"
          prop="addUserId"
          label="添加人"
        ></el-table-column>
        <el-table-column
          v-if="colData[17].istrue"
          prop="addTime"
          label="添加时间"
          width="180px"
        >
        </el-table-column>
        <el-table-column label="操作" width="150px" fixed="right">
          <!-- 作用域插槽 -->
          <template slot-scope="scope">
            <!-- 修改按钮 -->
            <el-button
              type="primary"
              icon="el-icon-edit"
              size="mini"
              @click="showEditDialog(scope.row.id)"
            ></el-button>
            <!-- 删除按钮 -->
            <el-button
              type="danger"
              icon="el-icon-delete"
              size="mini"
              @click="removeUserById(scope.row.id)"
            ></el-button>
          </template>
        </el-table-column>
      </el-table>
      <!-- 添加业主的对话框 -->
      <el-dialog
        title="添加业主"
        :visible.sync="addDialogVisible"
        width="50%"
        @close="addDialogReset"
      >
        <!-- 内容主题区域 -->
        <el-form
          :model="addForm"
          :rules="addFormRules"
          ref="addFormRef"
          label-width="100px"
          :inline="true"
        >
          <el-form-item label="姓名" prop="name">
            <el-input v-model="addForm.name"></el-input>
          </el-form-item>
          <el-form-item label="性别" prop="gender">
            <el-input v-model="addForm.gender"></el-input>
          </el-form-item>
          <el-form-item label="联系电话" prop="phone">
            <el-input v-model="addForm.phone"></el-input>
          </el-form-item>
          <el-form-item label="身份证号" prop="idCard">
            <el-input
              v-model="addForm.idCard"
              onkeyup="this.value=this.value.replace(/[^\X0-9]/g, '')"
            ></el-input>
          </el-form-item>
          <el-form-item label="房间id" prop="roomId">
            <el-input v-model="addForm.roomId" placeholder="请输入房间id"></el-input>
          </el-form-item>
          <el-form-item label="职业" prop="jobInfo">
            <el-input v-model="addForm.jobInfo"></el-input>
          </el-form-item>
          <el-form-item label="婚姻状况" prop="marryInfo">
            <el-select v-model="addForm.marryInfo" placeholder="请选择婚姻状况" class="select">
              <el-option label="未婚" value="未婚"></el-option>
              <el-option label="已婚" value="已婚"></el-option>
              <el-option label="离婚" value="离婚"></el-option>
              <el-option label="丧偶" value="丧偶"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="籍贯" prop="nativePlace">
            <el-input v-model="addForm.nativePlace"></el-input>
          </el-form-item>
          <el-form-item label="民族" prop="nation">
            <el-input v-model="addForm.nation"></el-input>
          </el-form-item>
          <el-form-item label="文化程度" prop="eduInfo">
            <el-select v-model="addForm.eduInfo" placeholder="请选择文化程度" class="select">
              <el-option label="博士" value="博士"></el-option>
              <el-option label="研究生" value="研究生"></el-option>
              <el-option label="本科" value="本科"></el-option>
              <el-option label="大专或中专" value="大专或中专"></el-option>
              <el-option label="高中" value="高中"></el-option>
              <el-option label="初中" value="初中"></el-option>
              <el-option label="小学" value="小学"></el-option>
              <el-option label="文盲" value="文盲"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="兵役状况" prop="militaryState">
             <el-radio-group v-model="addForm.militaryState">
                <el-radio :label="0">未服役</el-radio>
                <el-radio :label="1">服役</el-radio>
             </el-radio-group>
          </el-form-item>
          <el-form-item label="宗教信仰" prop="religious">
            <el-input v-model="addForm.religious"></el-input>
          </el-form-item>
        </el-form>
        <!-- 底部区域 -->
        <span slot="footer" class="dialog-footer">
          <el-button @click="addDialogVisible = false">取 消</el-button>
          <el-button type="primary" @click="addOwnerInfo">确 定</el-button>
        </span>
      </el-dialog>
      <!-- 修改业主信息的对话框 -->
      <el-dialog
        title="修改业主信息"
        :visible.sync="editDialogVisible"
        width="50%"
        @close="editDialogClosed"
      >
        <el-form
          ref="editFormRef"
          :model="editForm"
          label-width="100px"
          :rules="editFormules"
          :inline="true"
        >
          <el-form-item label="姓名" prop="name">
            <el-input v-model="editForm.name" disabled></el-input>
          </el-form-item>
          <el-form-item label="联系电话" prop="phone">
            <el-input v-model="editForm.phone"></el-input>
          </el-form-item>
          <el-form-item label="房间id" prop="roomId">
            <el-input v-model="editForm.roomId" placeholder="请输入房间id"></el-input>
          </el-form-item>
          <el-form-item label="职业" prop="jobInfo">
            <el-input v-model="editForm.jobInfo"></el-input>
          </el-form-item>
          <el-form-item label="婚姻状况" prop="marryInfo">
            <el-select v-model="editForm.marryInfo" placeholder="请选择婚姻状况" class="select">
              <el-option label="未婚" value="未婚"></el-option>
              <el-option label="已婚" value="已婚"></el-option>
              <el-option label="离婚" value="离婚"></el-option>
              <el-option label="丧偶" value="丧偶"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="籍贯" prop="nativePlace">
            <el-input v-model="editForm.nativePlace"></el-input>
          </el-form-item>
          <el-form-item label="文化程度" prop="eduInfo">
            <el-select v-model="editForm.eduInfo" placeholder="请选择文化程度" class="select">
              <el-option label="博士" value="博士"></el-option>
              <el-option label="研究生" value="研究生"></el-option>
              <el-option label="本科" value="本科"></el-option>
              <el-option label="大专或中专" value="大专或中专"></el-option>
              <el-option label="高中" value="高中"></el-option>
              <el-option label="初中" value="初中"></el-option>
              <el-option label="小学" value="小学"></el-option>
              <el-option label="文盲" value="文盲"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="兵役状况" prop="militaryState" >
             <el-radio-group v-model="editForm.militaryState" >
                <el-radio :label="0">未服役</el-radio>
                <el-radio :label="1">服役</el-radio>
             </el-radio-group>
          </el-form-item>
          <el-form-item label="宗教信仰" prop="religious">
            <el-input v-model="editForm.religious"></el-input>
          </el-form-item>
        </el-form>
        <!-- 底部区域 -->
        <span slot="footer" class="dialog-footer">
          <el-button @click="editDialogVisible = false">取 消</el-button>
          <el-button type="primary" @click="editOwnerInfo">确 定</el-button>
        </span>
      </el-dialog>
      <!-- 分页区域 -->
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="this.queryInfo.pageNum"
        :page-sizes="[3, 5, 10, 15]"
        :page-size="this.queryInfo.pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
      >
      </el-pagination>
    </div>
  </div>
</template>
<script>
import { isIdentityId } from '../../../utils/validate'
import axios from 'axios'
export default {
  data() {
    // 验证手机号
    var checkMobile = (rule, value, callback) => {
      // 验证邮箱的正则表达式
      const regMobile = /^(0|86|17951)?(13[0-9]|15[012356789]|17[678]|18[0-9]|19[0-9]|14[57])[0-9]{8}$/
      if (regMobile.test(value)) {
        // 合法的手机
        return callback()
      }
      callback(new Error('请输入合法的手机'))
    }
    //验证身份证号
    var checkIdentitytionId = (rule, value, callback) => {
      var errorMsg = isIdentityId(value);
      if (errorMsg != "") {
        callback(new Error(errorMsg));
      }else{
        callback()
      }
    }
    return {
      // 获取业主列表的参数对象
      queryInfo: {
        query: '',
        pageNum: 1,
        pageSize: 5
      },
      ownerInfoList: [],
      colData: [
        { title: "序号", istrue: true },
        { title: "姓名", istrue: true },
        { title: "性别", istrue: true },
        { title: "联系电话", istrue: true },
        { title: "房间号", istrue: true },
        { title: "楼栋号", istrue: true },
        { title: "单元号", istrue: true },
        { title: "职业", istrue: true },
        { title: "婚姻状况", istrue: true },
        { title: "籍贯", istrue: true },
        { title: "文化程度", istrue: true },
        { title: "兵役状况", istrue: true },
        { title: "客户类型", istrue: true },
        { title: "民族", istrue: true },
        { title: "身份证号", istrue: true },
        { title: "宗教信仰", istrue: true },
        { title: "添加人", istrue: true },
        { title: "添加时间", istrue: true },
      ],
      colOptions: [],//多选框默认全选
      colSelect: [],//所有表头标题,跟多选框单绑定的
      marryInfoValue:'',//筛选下拉框单选：婚姻状况
      eduInfoValue:[],//筛选下拉框多选：文化程度
      serviceValue:'',//筛选下拉框单选：兵役状况
      total: 0,
      // 控制添加对话框的显示与隐藏
      addDialogVisible: false,
      // 控制修改对话框的显示与隐藏
      editDialogVisible: false,
      // 添加业主的表单数据
      addForm: {
        name: '',
        gender: '',
        phone: '',
        idCard: '',
        userType: '',
        roomId: '',
        jobInfo: '',
        marryInfo: '',
        nativePlace: '',
        nation: '',
        eduInfo: '',
        militaryState: '',
        religious: '',
        addUserId: '',
        addTime: ''
      },
      //选中行的id数组
      multipleSelection: [],
      idsArray: {
        ids: []
      },
      // 查询到的编辑业主信息
      editForm: {},
      // 添加表单的验证规则对象
      addFormRules: {
        name: [{ required: true, message: '请输入姓名', trigger: 'blur' }],
        gender: [{ required: true, message: '请输入性别', trigger: 'blur' }],
        phone: [
          { required: true, message: '请输入联系电话', trigger: 'blur' },
          { validator: checkMobile, trigger: 'blur' }
        ],
        idCard: [
          { required: true, message: '请输入身份证号', trigger: 'blur' },
          { validator: checkIdentitytionId, trigger: "blur" }
        ],
        roomId: [{ required: true, message: '请输入房间id', trigger: 'blur' }],
        jobInfo: [{ required: true, message: '请输入职业', trigger: 'blur' }],
        nativePlace: [{ required: true, message: '请输入籍贯', trigger: 'blur' }],
        nation: [{ required: true, message: '请输入民族', trigger: 'blur' }],
      },
      // 修改业主信息表单的验证规则
      editFormules: {
        name: [{ required: true, message: '请输入姓名', trigger: 'blur' }],
        phone: [{ required: true, message: '请输入联系电话', trigger: 'blur' }],
        roomId: [{ required: true, message: '请输入房间id', trigger: 'blur' }],
        jobInfo: [{ required: true, message: '请输入职业', trigger: 'blur' }],
        nativePlace: [{ required: true, message: '请输入籍贯', trigger: 'blur' }],
      }

    }

  },
  created() {
    this.getOwnerInfoList()
    //初始化隐藏列
    var _this = this;
    for (let i = 0; i < _this.colData.length; i++) {
      _this.colSelect.push(_this.colData[i].title);
      if (_this.colData[i].title == '添加人' || _this.colData[i].title == '添加时间' || _this.colData[i].title == '身份证号' || _this.colData[i].title == '民族'|| _this.colData[i].title == '客户类型') { //初始化不想展示的列可以放在这个条件里
        continue;
      }
      _this.colOptions.push(_this.colData[i].title);
    }
  },
  watch: {
    // 单选列实现
    colOptions(valArr) {
      var arr = this.colSelect.filter(i => valArr.indexOf(i) < 0); // 未选中
      this.colData.filter(i => {
        if (arr.indexOf(i.title) != -1) {
          i.istrue = false;
        } else {
          i.istrue = true;
        }
      });
      this.$nextTick(() => {
        this.$refs.tableDataRef.doLayout();
      });
    }
  },
  methods: {
    // 获取业主档案列表
    async getOwnerInfoList() {
      // if (this.queryInfo.query !== '')
      //   //模糊查询业主名
      //   this.queryInfo.condition = `name like "%${this.queryInfo.query}%" and userType=0`
      // else
      //   this.queryInfo.condition = `userType=0`
      this.queryInfo = this.getQueryCondition()
      const { data: res } = await this.$http.get('BaseresidentinfoAction/getBasicInfos', { params: this.queryInfo })
      if (!res.success) return this.$message.error('获取业主列表失败')
      console.log(res)
      this.ownerInfoList = res.rows
      this.total = res.total
    },
    // //监听搜索输入框
    // clearData() {
    //   if (this.marryInfoValue == ''|| this.serviceValue==''|| this.eduInfoValue=='') {
    //     this.queryInfo.condition = `userType=0`
    //   }
    // },
    //点击按钮，添加业主
    addOwnerInfo() {
      this.$refs.addFormRef.validate(async valid => {
        if (!valid) return
        //给隐藏的input输入框中的添加人addUserId赋值
        this.addForm.addUserId = window.sessionStorage.getItem('userId')
        // 添加时间
        this.addForm.addTime = this.dateFormat()
        //console.log(this.addForm.addTime)
        this.addForm.userType = 0
        const { data: res } = await this.$http.post("BaseresidentinfoAction/addObject", this.addForm)
        if (!res.success) return this.$message.error('添加业主失败')
        //关闭对话框
        this.addDialogVisible = false
        //刷新数据列表
        this.getOwnerInfoList()
        this.$message.success('添加业主成功')
      })
    },
    // 展示编辑业主的对话框
    async showEditDialog(id) {
      const { data: res } = await this.$http.post("BaseresidentinfoAction/getObjectById", { id })
      if (!res.success)
        return this.$message.error('查询业主失败')
      this.editForm = res.rows[0]
      // console.log(this.editForm);
      this.editDialogVisible = !this.editDialogVisible
    },
    //点击按钮，修改业主信息
    editOwnerInfo() {
      this.$refs.editFormRef.validate(async valid => {
        if (!valid) return
        const { data: res } = await this.$http.post("BaseresidentinfoAction/updateNoNull", this.editForm)
        if (!res.success) return this.$message.error('修改区域信息失败')
        //关闭对话框
        this.editDialogVisible = false
        //刷新数据列表
        this.getOwnerInfoList()
        this.$message.success('修改业主信息成功')
      })
    },
    // 根据id删除业主
    async removeUserById(ids) {
      // 先弹框询问用户是否确定要删除
      const confirmResult = await this.$confirm('此操作将永久删除该业主, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).catch(err => {
        return err
      })
      // 如果点击取消返回的是字符串cancel
      // 如果点击确认返回的是字符串confirm
      if (confirmResult !== 'confirm') {
        return this.$message.info('取消了删除')
      }
      const { data: res } = await this.$http.post("BaseresidentinfoAction/deleteByIds", { ids })
      console.log(res);
      if (!res.success) {
        return this.$message.error('删除业主失败')
      }
      this.$message.success('删除业主成功')
      // 刷新列表
      this.getOwnerInfoList()
    },

    //批量删除
    async removeUserByIds() {
      const rows = this.$refs.tableDataRef.selection;
      if (rows.length === 0) {
        this.$message.warning('请选择需要操作的数据')
        return
      }
      else {
        // 先弹框询问用户是否确定要删除
        const confirmResult = await this.$confirm('此操作将永久删除该业主, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).catch(err => {
          return err
        })
        if (confirmResult !== 'confirm') {
          return this.$message.info('取消了删除')
        }
        const { data: res } = await this.$http.post("BaseresidentinfoAction/deleteByIds", this.idsArray)
        console.log(res);
        if (!res.success) {
          return this.$message.error('删除业主失败')
        }
        this.$message.success('删除业主成功')
        //此时全选框还是选中状态，批量删除后需清除选中状态
        this.$refs.tableDataRef.clearSelection();
        // 刷新列表
        this.getOwnerInfoList()
      }

    },
    //导出Excel表
    handleDownload() {
      window.open(axios.defaults.baseURL + '/BaseresidentinfoAction/exportDataToExcel?token=' + window.sessionStorage.getItem('token'))
    },
    //当多选框选择项发生变化时会触发该事件
    handleSelectionChange(val) {
      this.multipleSelection = val;
      this.idsArray.ids = [] //每次点击需清空原本数组的内容
      this.multipleSelection.map(item => { //遍历数组，把id存进自定义的数组里
        this.idsArray.ids.push(item.id)
      })
      this.idsArray.ids = this.idsArray.ids.join(',')
      // console.log(this.idsArray);

    },
    // 监听修改业主对话框的关闭事件
    editDialogClosed() {
      this.$refs.editFormRef.resetFields()
    },
    // 监听pageSize改变的事件
    handleSizeChange(newPageSize) {
      // console.log(newPageSize)
      this.queryInfo.pageSize = newPageSize
      // PageSize改变重新拿到业主列表
      this.getOwnerInfoList()
    },
    // 监听当前页码改变的事件
    handleCurrentChange(newPageNum) {
      // console.log(newPageNum)
      this.queryInfo.pageNum = newPageNum
      this.getOwnerInfoList()
    },
    addDialogReset() {
      // 拿到表单的引用进行重置
      this.$refs.addFormRef.resetFields()
    },
    filterTag(value, row) {
      return row.militaryState === value
    },
    // 全选或取消全选实现
    filterFunHandle(type, currentItem, index) {
      if (type === 'allchecked') { // 全选
        if (this.colSelect.length === 0) {
          this.colData.forEach((result) => {
            this.colSelect.push(result.title)
          })
          this.colOptions = this.colSelect // 复选框置为复选所有值，全部选择

        } else {
          this.colOptions = this.colSelect // 复选框置为复选所有值，全部选择

        }
      } else if (type === 'cancel') { // 取消全选
        this.colOptions = [] // 复选框置为空，全部不选择

      }
    },
    //工具栏的各种下拉框筛选监听
    async selectChange(){
      
      // if (this.marryInfoValue !== ''|| this.serviceValue!=''||this.eduInfoValue!='')
      // this.queryInfo = this.getQueryCondition()
      // const { data: res } = await this.$http.get('BaseresidentinfoAction/getBasicInfos', { params: this.queryInfo })
      // if (!res.success) return this.$message.error('获取业主列表失败')
      // console.log(res)
      // this.ownerInfoList = res.rows
      // this.total = res.total
      this.getOwnerInfoList()
    },
    //获取工具栏的各类查询条件：搜索框关键词、筛选框值等
    getQueryCondition(){
      //搜索框筛选
      var search = `and baseresidentinfo.name like "%${this.queryInfo.query}%"`;

      // 下拉框筛选
        var edulist = '';
        if (this.eduInfoValue.length != 0) {
          edulist += ` and(`;
          for (var i in this.eduInfoValue) {
            edulist += ` baseresidentinfo.eduInfo='${this.eduInfoValue[i]}'`
            if (i != this.eduInfoValue.length - 1) {
              edulist += ` or `
            }
          }
          edulist += `)`
        }
        var marryInfo = '';
        if (this.marryInfoValue !== '') {
          marryInfo += ` and baseresidentinfo.marryInfo='${this.marryInfoValue}'`;
        }
        var service = '';
        if (this.serviceValue !== '') {
          service += ` and baseresidentinfo.militaryState='${this.serviceValue}'`;
        }
        this.queryInfo.condition = ` userType=0 `+`${search}${marryInfo}${edulist}${service}`;
        
        return this.queryInfo;
    }
  }
}
</script>
<style lang="less" scoped>
.el-radio-group{
  width:202px
}

</style>